<?php
    require 'dbcon.php';//引入连接库连接文件      
    if( isset($_GET['search']) ) {
        $search = $_GET['search'];
        $sql="select * from tb_staff  where (name like '%{$search}%') or (department like '%{$search}%') or (birthday like '%{$search}%') or (entry like '%{$search}%')";// 升序asc  降序desc
    }else{
        $search='';
        $sql="select * from tb_staff";// 升序asc  降序desc
    }
    $result=$db->query($sql);//执行查询语句$sql，生成结果集$result
    $sql="select * from tb_staff";// 查询表格内容
//    $result=$db->query($sql);//执行查询语句$sql，生成结果集$result
    $num=$result->num_rows;
    //$bbsdata=$result->fetch_all(MYSQLI_NUM);//将结果集变成数组$bbsdata,是二维索引数组，下标是数字
    //$bbsdata=$result->fetch_all(MYSQLI_ASSOC);//将结果集变成数组$bbsdata,是二维关联数组，下标是字符串
    $staffdata=$result->fetch_all(MYSQLI_BOTH);//将结果集变成数组$bbsdata,是二维索引和关联数组，下标是数字或字符串
    $result->free_result();//释放结果集
    $db->close();//关闭数据连接
    require 'list_html.php';